package com.genghis.rapidcrm.web.controller;

import com.genghis.rapidcrm.web.view.HomeIndexView;
import com.genghis.rapidcrm.web.view.RapidIndexView;
import com.genghis.rapidcrm.web.view.RapidListView;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.View;

/**
 * @author xulixin
 */
@Controller
public class DashboardController {

    @RequestMapping("/groups")
    public View indexGroup() {
        return new HomeIndexView();
    }

    @RequestMapping("/modules")
    public View indexModule() {
        return new HomeIndexView();
    }

    @RequestMapping("/topmenu")
    public View indexTopMenu() {
        return new RapidIndexView();
    }

    @RequestMapping("/organizations")
    public View indexCompany() {
        return new HomeIndexView();
    }

    @RequestMapping("/company-info")
    public View showCompanyDetail() {
        return new RapidIndexView();
    }

    @RequestMapping("/permissions")
    public View indexPermisson() {
        return new HomeIndexView();
    }

    @RequestMapping("/roles")
    public View indexRole() {
        return new HomeIndexView();
    }

    @RequestMapping("/settings")
    public View indexSetting() {
        return new RapidIndexView();
    }

    @RequestMapping("/mail-server")
    public View showMailServer() {
        return new RapidIndexView();
    }

    @RequestMapping("/search")
    public View showSearch() {
        return new RapidIndexView();
    }

    @RequestMapping("/cron-task")
    public View showCronTask() {
        return new RapidIndexView();
    }

    @RequestMapping("/users")
    public View indexUser() {
        return new RapidListView();
    }

    @RequestMapping("/workflows")
    public View indexWorkflow() {
        return new HomeIndexView();
    }

    @RequestMapping("/Rapid/{action}")
    public View rapidModule(@PathVariable String action) {
        return new HomeIndexView();
    }

    @RequestMapping("/Settings/ModuleManager/List")
    public View addOrRemoveModule() {
        return new HomeIndexView();
    }

    @RequestMapping("/Settings/MenuEditor/Index")
    public View topmenu() {
        return new RapidIndexView();
    }

    @RequestMapping("/{moduleName}/showAdvancedSearch")
    public String showAdvancedSearch(@PathVariable String moduleName,
                                     @RequestParam("source_module") String sourceModule,
                                     Model model) {

        model.addAttribute("SOURCE_MODULE", sourceModule);
        model.addAttribute("MODULE", moduleName);
        return "/layout/modules/Vtiger/AdvanceSearch";
    }
}
